<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>订单管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript">
//展开订单商品列表
window.flag = false;
function showOrderProductsList(orderId){
	var _this = $('#order_pro_'+orderId);
    if(flag){
        return;
    }
    var tclass = _this.attr('act');
    flag = true;
    if(tclass=='show'){
        $.get('?m=product&s=order.php',{'order_id':orderId,'act':'getOrderProductList'},function(data){
            _this.parent().parent().after(data);
            _this.attr('act','hide');
            _this.attr('src','../image/admin/hidechild.png');
            flag = false;
        });
    }else if(tclass=='hide'){
        _this.parent().parent().next().remove();
        _this.attr('act','show');
        _this.attr('src','../image/admin/addchildboard.png');
        flag = false;
    }
}
</script>
</head>
<body>
<div class="container">
    <div class="flow">
        <div class="itemtitle">
            <h3>订单管理</h3>
            <ul>
                <li <{if $smarty.get.status==''}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}><{if $smarty.get.userid>0 }>&userid=<{$smarty.get.userid}><{/if}>"><span>管理</span></a></li>
                <{foreach item=list key=num from=$order_shop_status}>
                <li <{if $smarty.get.status==$num+1}>class="current"<{/if}>><a href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&status=<{$num+1}><{if $smarty.get.userid>0 }>&userid=<{$smarty.get.userid}><{/if}>"><span><{$list}></span></a></li>
              	<{/foreach}>
            </ul>
        </div>
    </div>
    <div class="h35"></div>
    <table class="select_table">
        <tr>    
            <td>
            	<div class="select_box">
                <form action="" method="get">
                    <input type="hidden" name="m" value="<{$smarty.get.m}>">
                    <input type="hidden" name="s" value="order.php">
                    <input type="hidden" name="onlytoday" value="<{$smarty.get.onlytoday}>">
                    <input type="hidden" name="status" value="<{$smarty.get.status}>">
										<select name="stock_shop" id="stock_shop" style="float:left;">
                <option value="" <{if $general_shop!=0}>disabled<{/if}>>全部</option>
                <{foreach item=list from=$stock_shops}>
                <option value="<{$list.id}>" <{if $smarty.get.stock_shop==$list.id}>selected<{/if}> <{if $general_shop!=0&&$general_shop!=$list.id}>disabled<{/if}>><{$list.title}></option>
                
                <{/foreach}>
                </select>
                    <input placeholder="请输入订单编号..." type="text" name="code" class="txt w250" value="<{$smarty.get.code}>" />
                    <input type="submit" value="搜索" />
                </form>
                </div>
                <div class="search">
                	<a class="a-search" href="#">高级搜索</a>
                	<div class="div-search">
                        <div class="close"></div>
                        <div class="line"></div>
                        <div class="search-con clearfix">
                        <form action="" method="get">
                        <input type="hidden" name="m" value="<{$smarty.get.m}>">
                        <input type="hidden" name="s" value="order.php">
                        <input type="hidden" name="status" value="<{$smarty.get.status}>">
                        <input type="hidden" name="stock_shop" id="stock_shop_t" value="<{$smarty.get.stock_shop}>">
                        <dl>
                            <dt>订单编号</dt>
                            <dd><input type="text" class="w250" name="code" value="<{$smarty.get.code}>" /></dd>
                        </dl>
                        <dl>
                            <dt>订单类型</dt>
                            <dd>
                            <select name="order_type" class="w250">
                            <option value="">--全部--</option>
                            <option <{if $smarty.get.order_type==1}>selected="selected"<{/if}> value="1">普通订单</option>
                            <option <{if $smarty.get.order_type==2}>selected="selected"<{/if}> value="2">分销订单</option>
                            <option <{if $smarty.get.order_type==3}>selected="selected"<{/if}> value="3">微店订单</option>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>支付状态</dt>
                            <dd>
                            <select name="order_pay_status" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$order_pay_status}>
                            <option <{if $smarty.get.order_pay_status==$key+1}>selected="selected"<{/if}> value="<{$key+1}>"><{$list}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>支付方式</dt>
                            <dd>
                            <select name="pay" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$pay}>
                            <option <{if $smarty.get.pay==$list.payment_id}>selected="selected"<{/if}> value="<{$list.payment_id}>"><{$list.payment_name}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>  
                        <dl>
                            <dt>支付平台</dt>
                            <dd>
                            <select name="client_platform" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$client_platform}>
                            <option <{if $smarty.get.client_platform!=''}><{if $key==$smarty.get.client_platform}>selected="selected"<{/if}><{/if}> value="<{$key}>"><{$list}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>操作系统</dt>
                            <dd>
                            <select name="client_system" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$client_system}>
                            <option <{if $smarty.get.client_system!=''}><{if $key==$smarty.get.client_system}>selected="selected"<{/if}><{/if}> value="<{$key}>"><{$list}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>配送状态</dt>
                            <dd>
                            <select name="order_ship_status" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$order_ship_status}>
                            <option <{if $smarty.get.order_ship_status==$key+1}>selected="selected"<{/if}> value="<{$key+1}>"><{$list}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>配送方式</dt>
                            <dd>
                            <select name="ship" class="w250">
                            <option value="">请选择</option>
                            <{foreach item=list key=key from=$ship}>
                            <option <{if $smarty.get.ship==$list.id}>selected="selected"<{/if}> value="<{$list.id}>"><{$list.title}></option>
                            <{/foreach}>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>供应类型</dt>
                            <dd>
                            <select name="separate_status" class="w250">
                            <option value="">请选择</option>
                            <option value="0" <{if $smarty.get.separate_status=='0'}>selected<{/if}>>自营</option>
                            <option value="-1" <{if $smarty.get.separate_status==-1}>selected<{/if}>>供应商</option>
                            </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>物流单号</dt>
                            <dd>
                            <input type="text" class="w250" name="shipping_no" value="<{$smarty.get.shipping_no}>" />
                            </dd>
                        </dl>                        
                        <dl>
                            <dt>订单总额</dt>
                            <dd>
                            <input type="text" class="w118" name="minp" value="<{$smarty.get.minp}>" />
                            -
							<input type="text" class="w118" name="maxp" value="<{$smarty.get.maxp}>" />
                            </dd>
                        </dl>
                        <dl>
                            <dt>下单时间</dt>
                            <dd>
                            <script language="javascript">
            var cdr = new Calendar("cdr");
            document.write(cdr);
            cdr.showMoreDay = true;
        </script>
                            <input onFocus="cdr.show(this);" class="w118" type="text" name="stime" id="stime" value="<{$smarty.get.stime}>"">
                            -
							<input onFocus="cdr.show(this);" class="w118" type="text" name="etime" id="etime" value="<{$smarty.get.etime|default:$smarty.now+86399|date_format:'%Y-%m-%d'}>"">
                            </dd>
                        </dl>                        
                        <dl>
                            <dt>支付时间</dt>
                            <dd>
                            <script language="javascript">
            var pcdr = new Calendar("pcdr");
            document.write(pcdr);
            pcdr.showMoreDay = true;
        </script>
                            <input onFocus="pcdr.show(this);" class="w118" type="text" name="p_stime" id="p_stime" value="<{$smarty.get.p_stime}>"">
                            -
                            <input onFocus="pcdr.show(this);" class="w118" type="text" name="p_etime" id="p_etime" value="<{$smarty.get.p_etime|default:$smarty.now+86399|date_format:'%Y-%m-%d'}>"">
                            </dd>
                        </dl>                        
                        <dl>
                            <dt>发货时间</dt>
                            <dd>
                            <script language="javascript">
            var scdr = new Calendar("scdr");
            document.write(scdr);
            scdr.showMoreDay = true;
        </script>
                            <input onFocus="scdr.show(this);" class="w118" type="text" name="s_stime" id="s_stime" value="<{$smarty.get.s_stime}>"">
                            -
                            <input onFocus="scdr.show(this);" class="w118" type="text" name="s_etime" id="s_etime" value="<{$smarty.get.s_etime|default:$smarty.now+86399|date_format:'%Y-%m-%d'}>"">
                            </dd>
                        </dl>
                        <dl>
                            <dt>买家名称</dt>
                            <dd><input type="text" class="w250" name="user" value="<{$smarty.get.user}>" /></dd>
                        </dl>
                        <dl>
                            <dt>收货人</dt>
                            <dd><input type="text" class="w250" name="ship_name" value="<{$smarty.get.ship_name}>" /></dd>
                        </dl>
                        <dl>
                            <dt>收货地址</dt>
                            <dd><input type="text" class="w250" name="ship_addr" value="<{$smarty.get.ship_addr}>" /></dd>
                        </dl>
                    	<input type="submit" value="搜索" />
                        </form>
                        </div>
                    </div>
                </div>
                <a class="refresh" href="?m=<{$smarty.get.m}>&s=<{$smarty.get.s}>&status=<{$smarty.get.status}>"></a>
                
                 <form method="post" target="export_iframe" id="export_form" action="">
                 		<input type="hidden" value="export" name="act"/>
                 </form>
    <iframe src="" style="display:none;" id="export_iframe" name="export_iframe"></iframe>
    <div style="float:right" id="els_export">
   	 		<a href="javascript:;" onclick="showSellAmount('<{$amountCond}>');">显示总销售额</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:;" onclick="$('#export_form').submit();">导出EXCEL</a></div>
           </td>
        </tr>
    </table>
    <table class="table product">
       <tbody>
       <tr class="header">
            <th width="15"></th>
            <th width="40">查看</th>
            <th width="60">操作</th>
            <th width="60">打印</th>
            <th class="al">订单编号</th>
            <th width="130">订单总额</th>
            <th width="130">商品总价</th>
            <th width="100">买家名称</th>
            <th width="100">收货人</th>
            <th width="100">平台/系统</th>
            <th width="100">下单时间</th>
            <th width="110">订单状态</th>
            <th width="110">支付状态</th>
            <th width="110">配送状态</th>
            <th width="80">配送方式</th>
            <th width="80">支付方式</th>
        </tr>
        <{foreach item=list key=key from=$de.list}>
        <tr class="<{if $list.status==1}>bold<{/if}>">
            <td><img id="order_pro_<{$list.order_id}>" act="show" style="cursor:pointer;width:14px;height:14px;" onclick="showOrderProductsList('<{$list.order_id}>');" src="../image/admin/addchildboard.png" alt="" /></td>
            <td><a href="?m=product&s=order_detail.php&oid=<{$list.order_id}>">查看</a></td>
            <td>
            <{if $list.status!=0 and $list.status!=4}>
            <div class="operate">
                <a class="opear" href="#">操作<i></i></a>
                <ul>
<{if ($list.status==1&&$list.pay_status==1) || ($list.status==2&&$list.pay_status==2)}><li><a class="a-opear" data-type="edit" data-param="{'id':'<{$list.order_id}>'}" href="#">编辑</a></li><{/if}>
<!-- <{if $list.pay_status==1}><li><a class="a-opear" data-type="pay" data-param="{'id':'<{$list.order_id}>'}" href="#">付款</a></li><{/if}> -->
<{if $list.status==2&&$list.pay_status==2&&$list.inventory_status==1}><li><a class="a-opear" data-type="ship" data-param="{'id':'<{$list.order_id}>'}" href="#">发货</a></li><{/if}>
<{if $list.status==3&&$list.pay_status==2&&$list.ship_status==2}><li><a href="module.php?m=product&s=order.php&orderid=<{$list.order_id}><{$cond}>">完成</a></li><{/if}>
<{if $list.status==5}><li><a href="module.php?m=product&s=order.php&act=reback&orderid=<{$list.order_id}><{$cond}>">退货</a></li><{/if}>
<li><a class="a-opear" data-type="remark" data-param="{'id':'<{$list.order_id}>'}" href="#">备注</a></li>
<{if $list.status==3}>
<li><a class="a-opear" data-type="edit_shipped" data-param="{'id':'<{$list.order_id}>'}" href="#">编辑</a></li>
<{else}>
<li><a class="a-opear" data-type="cancel" data-param="{'id':'<{$list.order_id}>'}" href="#">取消</a></li>
<{/if}>

                </ul>
            </div>
            <{elseif $list.status==4}>
<a class="a-opear" data-type="remark" data-param="{'id':'<{$list.order_id}>'}" href="#">备注</a>

            <{else}>
            已取消
            <{/if}>
            </td>
            <td>
            <{if $list.status!=0 and $list.status!=1 and $list.pay_status!=1}>
            <div class="operate">
                <a class="opear" href="#"><{if $list.print_status==1}>已打印<{else}>打印<{/if}><i></i></a>
                <ul>
				<li><a class="a-opear" data-type="sendprint" data-param="{'id':'<{$list.order_id}>'}" href="#">发货单</a></li>
				<li><a class="a-opear" data-type="expressprint" data-param="{'id':'<{$list.order_id}>'}" href="#">快递单</a></li>
                </ul>
            </div>
            <{elseif $list.status==0}>
            已取消
            <{else}>
           待付款
            <{/if}>
            </td>
            
            <td class="al" style="position:relative;padding-left:32px;">
            <{if $list.stock_shop}><i style="background:url(/image/admin/<{$list.stock_shop}>.png);display: block;height: 32px;left: 0;top:50%; margin-top:-16px;position: absolute;width: 32px;"></i><{/if}><{$list.order_id}><br /><{if $list.shipping_no != ''}>[<{$list.shipping_no}>]<{/if}>
            <{if $list.master_order_id>0}>
            	<br /><a style="border:1px solid;" href="?m=product&s=order_detail.php&oid=<{$list.master_order_id}>" title="点击查看主订单详情">子订单</a>
            <{/if}>
            </td>
            <td class="price_detail">
                <{$config.money}><b><{$list.sum|number_format:2}></b>
<!--                 <{$config.money}><b><{$list.sum|number_format:2}></b><br /><{if $list.discount != 0}>[-<{$config.money}><{$list.discount|number_format:2}>]<{/if}><{if $list.cpns_price != 0}>[-<{$config.money}><{$list.cpns_price|number_format:2}>]<{/if}> -->
                <table class="price_detail_box bold">
                    <tr><td>活动优惠：</td><td>-<{$config.money}><{$list.discount|number_format:2}></td></tr>
                    <tr><td>代金券：</td><td>-<{$config.money}><{$list.cpns_price|number_format:2}></td></tr>
                    <tr><td>运费：</td><td>&nbsp;<{$config.money}><{$list.freight|number_format:2}></td></tr>
                    <tr><td>行邮税：</td><td>&nbsp;<{$config.money}><{$list.tax_price|number_format:2}></td></tr>
                    <tr><td>保险费：</td><td>&nbsp;<{$config.money}><{$list.insurance_fee|number_format:2}></td></tr>
                    <tr><td>余额支付：</td><td>-<{$config.money}><{$list.cash_price|number_format:2}></td></tr>
                    <tr><td>实际支付：</td><td>&nbsp;<{$config.money}><{$list.sum-$list.cash_price|number_format:2}></td></tr>
                </table>
            </td>
<!--             <td><{$config.money}><{$list.cost|number_format:2}><br /><{if $list.freight != 0}>[<{$config.money}><{$list.freight|number_format:2}>]<{/if}></td> -->
            <td><{$config.money}><{$list.cost|number_format:2}></td>
            <td><a href="?m=product&s=order.php&userid=<{$list.member_id}>"><{if $list.mobile}><{$list.mobile}><{else}><{$list.email}><{/if}><br/><{if $list.order_type==2}><b>(分销订单)</b><{/if}><{if $list.order_type==3}><b>(微店订单)</b><{/if}></a><{if $list.order_type==3}><br/><p>店铺ID:<{$list.ms_id}></p><{/if}></td>
            <td><{$list.ship_name}></td>
            <td><{$client_platform[$list.client_platform]}>/<{$client_system[$list.client_system]}></td>
            <td><{$list.order_time|date_format:"%Y-%m-%d<br>%H:%M:%S"}></td>
            <td>
            <{if $list.finished_time}><{$list.finished_time}></br><{/if}>
            <{$list.statu_text}>
            <br /><{if $list.status==2}><{if $list.inventory_status}><b>(备货完成)</b><{else}>(备货中)<{/if}><{/if}>
            </td>
            <td>
                <{if $list.pay_time}><{$list.pay_time}></br><{/if}>
                <{$list.order_pay_status}>
            </td>
            <td>
                <{if $list.ship_time}><{$list.ship_time}></br><{/if}>
                <{$list.order_ship_status}>
            </td>
            <td><{$list.shipping_name}></td>
            <td><{$list.payment_name}></td>
        </tr>
        <{foreachelse}>
        <tr>
            <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
        </tr>
        <{/foreach}>
		</tbody>
        <tfoot>
            <tr>
                <td colspan="99">
                	<div class="fl">每页最多显示： 20条</div>
                    <div class="page"><{$de.page}></div>
                    <div class="fr">共有<{$de.count}>条记录</div>
                </td>
            </tr>
        </tfoot>
    </table>
<script>
$(".a-opear").live('click',function(){
	
	var data = $(this).attr('data-param');
	eval("data = "+data);
	var type = $(this).attr('data-type');
	if(!data.id)
	{
		error('error','对不起，请选择订单后操作！');
		return false;
	}
	
	if(type=='sendprint'){
    	window.parent.iframe_form("sendprint", '发货单打印', '<{$config.weburl}>/admin/module.php?m=logistics&s=print.php&type=sendprint&oid='+data.id, 850,500);
		return false;
	}
	else if(type=='expressprint'){
    	window.parent.iframe_form("expressprint", '快递单打印', '<{$config.weburl}>/admin/module.php?m=logistics&s=print.php&type=expressprint&oid='+data.id, 900,580);
		return false;
	}
	
	window.parent.ajax_form("order", "操作订单", '<{$config.weburl}>/admin/module.php?m=product&s=order_opear.php&type='+type+'&orderid='+data.id, 800);
	return false;
	
});
$('.operate').hover(function(){					 
	if ($(this).position().top + $(this).children("ul").height() + $(this).parent("td").height() - $(window).height()- $(window).scrollTop()  < 0) {
		$(this).addClass("hover");
		$(this).children("ul").css("top", "22px");
	} else {
		$(this).addClass("hover-up");
		$(this).children("ul").css("top", -$(this).children("ul").height());
	}
},function(){
	$(this).removeClass("hover").removeClass("hover-up");	
});
$('.search').bind("mouseenter", function (e) {
	$(this).addClass("hover");
}).bind("mouseleave", function (e) {
	//$(this).removeClass("hover");
});
$('.close').bind("click", function (e) {
	$(this).parent().parent().removeClass("hover");
}) 
$('#stime,#p_stime,#s_stime').click(function () {
	var left = $("#Calendar").css("left");
	left = left.substring(0,left.length-2);
	left = left - 359;
	left = left+"px";
	var top = $("#Calendar").css("top");
	top = top.substring(0,top.length-2);
	top = top - 90;
	top = top+"px";
	$("#Calendar").css("left",left);
	$("#Calendar").css("top",top);
}) 
$('#etime,#p_etime,#s_etime').click(function () {
	var left = $("#Calendar").css("left");
	left = left.substring(0,left.length-2);
	left = left - 359;
	left = left+"px";
	var top = $("#Calendar").css("top");
	top = top.substring(0,top.length-2);
	top = top - 90;
	top = top+"px";
	$("#Calendar").css("left",left);
	$("#Calendar").css("top",top);
}) 
$('#stock_shop').bind('change',function(){
	$('#stock_shop_t').val($(this).val());
});
$(function(){
	$('.price_detail').hover(function(){
		$(this).parent().parent().find('.price_detail_box').hide();
		$(this).find('.price_detail_box').show();
	},function(){
		$(this).find('.price_detail_box').hide();
	});
});

//显示总销售额
function showSellAmount(cond){
	$.post('<{$config.weburl}>/admin/module.php?m=product&s=order_opear.php',{"act":"getSellAmountByCond","cond":cond},function(s){
		window.parent.html_form('sellAmount','总销售额',s,800,300);
	});
}
</script>    
</div>
</body>
</html>